package com.hue.springcloud.utils;

import cn.hutool.core.lang.Snowflake;
import org.springframework.stereotype.Component;

@Component
public class ProductIdUtils {
    private final long workId=1;
    private final long dataCenterId=1;
    private Snowflake snowflake=new Snowflake(workId, dataCenterId);

    public synchronized String getId(){
        return snowflake.nextIdStr();
    }

    public synchronized String getId(long wordId,long dataCenterId){
        return new Snowflake(wordId,dataCenterId).nextIdStr();
    }
}
